﻿using System;
using System.Configuration;

namespace mvcForum.Core.Configuration {

	public class MVCForumSection : ConfigurationSection {
		internal const String databaseBuilder = "databaseBuilder";
		internal const String dependencyContainerBuilder = "dependencyContainerBuilder";
		internal const String searchBuilders = "searchBuilders";
		internal const String contentParserComponents = "contentParserComponents";
		internal const String eventListenerComponents = "eventListenerComponents";
		internal const String repositoryComponents = "repositoryComponents";
		internal const String themeProviderComponent = "themeProviderComponent";
		internal const String eventPublisherComponent = "eventPublisherComponent";
		internal const String themeUrlProviderComponent = "themeUrlProviderComponent";
		internal const String asyncTaskComponent = "asyncTaskComponent";
		internal const String urlProviderComponent = "urlProviderComponent";
		internal const String mailServiceComponent = "mailServiceComponent";
		internal const String membershipServiceComponent = "membershipServiceComponent";
		internal const String formsAuthenticationComponent = "formsAuthenticationComponent";
		internal const String userProviderComponent = "userProviderComponent";
		internal const String storageBuilder = "storageBuilder";
		internal const String additionalBuilders = "additionalBuilders";
		internal const String loggingProviderComponent = "loggingProviderComponent";

		public MVCForumSection() { }

		/*
			Unique elements!
		*/

		[ConfigurationProperty(databaseBuilder)]
		public UniqueComponentElement DatabaseBuilder {
			get {
				return (UniqueComponentElement)base[databaseBuilder];
			}
		}

		[ConfigurationProperty(dependencyContainerBuilder)]
		public UniqueComponentElement DependencyContainerBuilder {
			get {
				return (UniqueComponentElement)base[dependencyContainerBuilder];
			}
		}

		[ConfigurationProperty(themeProviderComponent)]
		public ThemeProviderComponentElement ThemeProviderComponent {
			get {
				return (ThemeProviderComponentElement)base[themeProviderComponent];
			}
		}

		[ConfigurationProperty(themeUrlProviderComponent)]
		public ThemeUrlProviderComponentElement ThemeUrlProviderComponent {
			get {
				return (ThemeUrlProviderComponentElement)base[themeUrlProviderComponent];
			}
		}

		[ConfigurationProperty(eventPublisherComponent)]
		public EventPublisherComponentElement EventPublisherComponent {
			get {
				return (EventPublisherComponentElement)base[eventPublisherComponent];
			}
		}

		[ConfigurationProperty(asyncTaskComponent)]
		public AsyncTaskComponentElement AsyncTaskComponent {
			get {
				return (AsyncTaskComponentElement)base[asyncTaskComponent];
			}
		}

		[ConfigurationProperty(loggingProviderComponent)]
		public LoggingProviderComponentElement LoggingProviderComponent {
			get {
				return (LoggingProviderComponentElement)base[loggingProviderComponent];
			}
		}

		[ConfigurationProperty(urlProviderComponent)]
		public UrlProviderComponentElement UrlProviderComponent {
			get {
				return (UrlProviderComponentElement)base[urlProviderComponent];
			}
		}

		[ConfigurationProperty(mailServiceComponent)]
		public MailServiceComponentElement MailServiceComponent {
			get {
				return (MailServiceComponentElement)base[mailServiceComponent];
			}
		}

		[ConfigurationProperty(membershipServiceComponent)]
		public MembershipServiceComponentElement MembershipServiceComponent {
			get {
				return (MembershipServiceComponentElement)base[membershipServiceComponent];
			}
		}

		[ConfigurationProperty(formsAuthenticationComponent)]
		public FormsAuthenticationComponentElement FormsAuthenticationComponent {
			get {
				return (FormsAuthenticationComponentElement)base[formsAuthenticationComponent];
			}
		}

		[ConfigurationProperty(userProviderComponent)]
		public UserProviderComponentElement UserProviderComponent {
			get {
				return (UserProviderComponentElement)base[userProviderComponent];
			}
		}

		[ConfigurationProperty(storageBuilder)]
		public UniqueComponentElement StorageBuilder {
			get {
				return (UniqueComponentElement)base[storageBuilder];
			}
		}

		/*
			Collections
		*/

		[ConfigurationProperty(searchBuilders, IsDefaultCollection = false)]
		[ConfigurationCollection(typeof(NamedComponentsElementCollection), AddItemName = "add", ClearItemsName = "clear", RemoveItemName = "remove")]
		public NamedComponentsElementCollection SearchBuilders {
			get {
				return (NamedComponentsElementCollection)base[searchBuilders];
			}
		}

		[ConfigurationProperty(additionalBuilders, IsDefaultCollection = false)]
		[ConfigurationCollection(typeof(NamedComponentsElementCollection), AddItemName = "add", ClearItemsName = "clear", RemoveItemName = "remove")]
		public NamedComponentsElementCollection AdditionalBuilders {
			get {
				return (NamedComponentsElementCollection)base[additionalBuilders];
			}
		}

		[ConfigurationProperty(contentParserComponents, IsDefaultCollection = false)]
		[ConfigurationCollection(typeof(NamedComponentsElementCollection), AddItemName = "add", ClearItemsName = "clear", RemoveItemName = "remove")]
		public NamedComponentsElementCollection ContentParserComponents {
			get {
				return (NamedComponentsElementCollection)base[contentParserComponents];
			}
		}

		[ConfigurationProperty(eventListenerComponents, IsDefaultCollection = false)]
		[ConfigurationCollection(typeof(NamedComponentsElementCollection), AddItemName = "add", ClearItemsName = "clear", RemoveItemName = "remove")]
		public NamedComponentsElementCollection EventListenerComponents {
			get {
				return (NamedComponentsElementCollection)base[eventListenerComponents];
			}
		}

		public static MVCForumSection Get(System.Configuration.Configuration config) {
			if (config == null) {
				throw new ArgumentNullException("config");
			}
			return config.GetSection("mvcForum") as MVCForumSection;
		}
	}
}